home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / IEditor / Generators / E / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-17  |  3.3 KB  |  134 lines

  1. /// Includes
  2. #define INTUI_V36_NAMES_ONLY
  3.  
  4. #include <exec/types.h>                 // exec
  5. #include <exec/lists.h>
  6. #include <exec/nodes.h>
  7. #include <dos/dos.h>                    // dos
  8. #include <dos/dostags.h>
  9. #include <libraries/reqtools.h>         // libraries
  10. #include <clib/exec_protos.h>           // protos
  11. #include <clib/dos_protos.h>
  12. #include <clib/reqtools_protos.h>
  13. #include <pragmas/exec_pragmas.h>       // pragmas
  14. #include <pragmas/dos_pragmas.h>
  15. #include <pragmas/reqtools_pragmas.h>
  16.  
  17. #include <stdlib.h>
  18. #include <stdio.h>
  19.  
  20. #include "DEV_IE:Generators/defs.h"
  21. #include "DEV_IE:Include/IEditor.h"
  22.  
  23. #include "Protos.h"
  24. ///
  25.  
  26.  
  27. /// AskFile
  28. BOOL AskFile( UBYTE *File, struct IE_Data *IE )
  29. {
  30.     BOOL    ret = TRUE;
  31.     BPTR    lock;
  32.  
  33.     if( lock = Lock( File, ACCESS_READ )) {
  34.  
  35.     UnLock( lock );
  36.  
  37.     ULONG   tags[] = { RT_ReqPos, REQPOS_CENTERSCR, RT_Underscore, '_',
  38.                RT_Screen, IE->ScreenData->Screen, TAG_DONE };
  39.  
  40.     ret = rtEZRequest( "%s alreay exists.\n"
  41.                "Overwrite?",
  42.                "_Yes|_No",
  43.                NULL, (struct TagItem *)tags,
  44.                FilePart( File )
  45.              );
  46.     }
  47.  
  48.     return( ret );
  49. }
  50. ///
  51. /// WriteList
  52. void WriteList( struct GenFiles *Files, struct MinList *List, UBYTE *Label, UWORD Num, struct IE_Data *IE )
  53. {
  54.     struct GadgetScelta *gs;
  55.     UWORD                cnt;
  56.  
  57.     if( Num ) {
  58.  
  59.     FPrintf( Files->Std, "\nstruct Node %sNodes[] = {\n\t", Label );
  60.  
  61.     gs = List->mlh_Head;
  62.  
  63.     if( Num == 1 ) {
  64.         FPrintf( Files->Std, "(struct Node *)&%sList.mlh_Tail, (struct Node *)&%sList.mlh_Head, 0, 0, ",
  65.              Label, Label );
  66.  
  67.         if( IE->C_Prefs & SMART_STR )
  68.         FPrintf( Files->Std, "%s", (FindString( &Files->Strings, gs->gs_Testo ))->Label );
  69.         else
  70.         FPrintf( Files->Std, "\"%s\"", gs->gs_Testo );
  71.  
  72.         FPuts( Files->Std, " };\n" );
  73.     } else {
  74.  
  75.         FPrintf( Files->Std, "&%sNodes[1], (struct Node *)&%sList.mlh_Head, 0, 0, ",
  76.              Label, Label );
  77.  
  78.         if( IE->C_Prefs & SMART_STR )
  79.         FPrintf( Files->Std, "%s", (FindString( &Files->Strings, gs->gs_Testo ))->Label );
  80.         else
  81.         FPrintf( Files->Std, "\"%s\"", gs->gs_Testo );
  82.  
  83.         FPuts( Files->Std, ",\n" );
  84.  
  85.         for( cnt = 1; cnt < Num - 1; cnt++ ) {
  86.  
  87.         gs = gs->gs_Node.ln_Succ;
  88.  
  89.         FPrintf( Files->Std, "\t&%sNodes[%ld], &%sNodes[%ld], 0, 0, ",
  90.              Label, cnt + 1, Label, cnt - 1 );
  91.  
  92.         if( IE->C_Prefs & SMART_STR )
  93.             FPrintf( Files->Std, "%s", (FindString( &Files->Strings, gs->gs_Testo ))->Label );
  94.         else
  95.             FPrintf( Files->Std, "\"%s\"", gs->gs_Testo );
  96.  
  97.         FPuts( Files->Std, ",\n" );
  98.         }
  99.  
  100.         gs = gs->gs_Node.ln_Succ;
  101.         FPrintf( Files->Std, "\t(struct Node *)&%sList.mlh_Tail, &%sNodes[%ld], 0, 0, ",
  102.              Label, Label, Num - 2 );
  103.  
  104.         if( IE->C_Prefs & SMART_STR )
  105.         FPrintf( Files->Std, "%s", (FindString( &Files->Strings, gs->gs_Testo ))->Label );
  106.         else
  107.         FPrintf( Files->Std, "\"%s\"", gs->gs_Testo );
  108.  
  109.         FPuts( Files->Std, " };\n" );
  110.     }
  111.  
  112.     FPrintf( Files->Std, "\nstruct MinList %sList = {\n"
  113.                  "\t(struct MinNode *)&%sNodes[0], (struct MinNode *)NULL, (struct MinNode *)&%sNodes[%ld] };\n",
  114.          Label, Label, Label, Num - 1 );
  115.     }
  116. }
  117. ///
  118. /// WriteCD
  119. void WriteCD( struct GenFiles *Files )
  120. {
  121.     struct StringNode  *str;
  122.     UWORD               cnt = 0;
  123.  
  124.     for( str = Files->Strings.mlh_Head; str->Next; str = str->Next ) {
  125.  
  126.     FPrintf( (BPTR)Files->User1, "MSG_STRING_%ld (//)\n%s\n;\n",
  127.          cnt, str->String );
  128.  
  129.     cnt += 1;
  130.     }
  131. }
  132. ///
  133.  
  134.